package com.kanasco.engg.controller;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

import bb.access.po.Part;
import bb.common.PartPK;
import bb.common.PartUnitVO;
import bb.common.PartVO;

import com.kanasco.engg.model.Item;
import com.kanasco.engg.services.IItemService;

public class EngItemController extends SimpleFormController{
	public IItemService itemService;
	
	public EngItemController(){
		setCommandClass(Item.class);
		setCommandName("item");
	}
	
	
	
	public ModelAndView onSubmit(Object command,BindException errors)throws Exception{
		Item item=(Item) command;
		System.out.println("Part values :"+item);
		Part vo=new Part();
		
		PartPK pk=new PartPK();
		
		pk.setPartNumber(item.getPartNumber());
		pk.setPartType(item.getPartType());
		vo.setPk(pk);
		vo.setRevision(item.getRevision());
		vo.setDescription(item.getDescription());
		vo.setOrigin("admin");
		vo.setPartUnit(item.getPartUnit());
		vo.setLastUser("prasad");
		itemService.insertItem(vo);
		
		String url=getSuccessView();
		return new ModelAndView(url,"item",item);
		
	}




	public void setItemService(IItemService itemService) {
		this.itemService = itemService;
	}
	
	

}
